<?php


class Model_Dbtable_Wowmenu extends Zend_Db_Table_Abstract
{
    /**
     * The default table name 
     */
    protected $_name = 'db_wow_menu';
    
    //魔兽数据库 主菜单
	public function menu(){
		$menuclass = new Model_Dbtable_Wowmenuclass();
		$menusub   = new Model_Dbtable_Wowmenusub();
		
		$query = $this->getAdapter()->query("SELECT * FROM $this->_name WHERE 1=1 ORDER BY id ");
		$results = array();
		$i = 0;

		while ($value = $query->fetch()){
			//$results[$i][id]	= $value[id];
		    $results[$i][name]	= $value[name];
		    $results[$i][url]	= $value[url];
		    
		    //CLASS
			$query2 = $menuclass->showclass($value[id]);
			$m = 0;
			while ($value2 = $query2->fetch()){
				$results[$i][class_name][$m][class_id]		= $value2[class_id];
				$results[$i][class_name][$m][class_name]	= $value2[class_name];

			
				//SUB
				$query3 = $menusub->showsub($value2[class_id]);
				$n = 0;
				while ($value3 = $query3->fetch()){
					$results[$i][class_name][$m][sub_name][$n][sub_id]		= $value3[sub_id];
					$results[$i][class_name][$m][sub_name][$n][sub_name]	= $value3[sub_name];
					$n++;
				}
				$m++;
			}
		    $i++;	
		}

		return $results;
	}
	
	public function menuname($url){
		$menuname = $this->fetchRow("url = '$url'");
		return $menuname;
	}
	
	public function allmenu(){
		$menu = $this->fetchAll(NULL, "id");
		
		return $menu;
	}
}
